package top.ivansong92.example.leetcode.learning.data.struct.linklist.extension;

import top.ivansong92.example.leetcode.learning.data.struct.array.extension.stack.NewStack;

public class NewLinkedStack<E> implements NewStack<E> {
    private NewLinkedListV2<E> list;

    public NewLinkedStack() {
        this.list = new NewLinkedListV2<>();
    }

    @Override
    public int getSize() {
        return list.size();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }

    @Override
    public void push(E e) {
        list.addFirst(e);
    }

    @Override
    public E pop() {
        return list.removeLast();
    }

    @Override
    public E peek() {
        return list.getFirst();
    }
}
